package gulimall.feign;

import gulimall.to.SkuReductionTo;
import gulimall.to.SpuBoundTo;
import gulimall.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author HLF
 * @since 2022/5/10 11:24
 */
@Service
@FeignClient(value = "gulimall-coupon", path = "/coupon")
public interface CouponFeignService {

    /**
     * 1.couponFeignService.save(spuBoundTo);//调用该方法
     * 2.@RequestBody将这个对象转换为json
     * 3.SpringCloud会找到gulimall-coupon服务，给/coupon/spubounds/save发送请求，
     * 将上一步的json放到请求体的位置，发送请求
     * 4.目标服务收到请求，该请求的请求体里含有json数据，
     * 对方服务的@RequestBody将json转换为SpuBoundsEntity对象
     * 总结：只要json数据模型是兼容的，双方服务无需使用同一个TO
     * ❗️5.如果含有@RequestBoy数据，一定要使用@PostMapping发动请求
     *
     * @param spuBoundTo
     * @return
     */
    @RequestMapping("/spubounds/save")
    R save(@RequestBody SpuBoundTo spuBoundTo);

    @PostMapping("/skufullreduction/saveinfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
